home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 2 / Gekikoh Dennoh Club Vol. 2 (Japan).7z / Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin / kowin / util / sclock.lzh / sclock.c next >
C/C++ Source or Header  |  1993-02-17  |  2KB  |  81 lines

  1. /*    1993 H.Ogasawara (COR.)        */
  2.  
  3. /*    時計のサンプルプログラム    */
  4. /*    非常にシンプルな時計です。スケルトンプログラムとしてどうぞ。    */
  5.  
  6. #include    <corlib.h>
  7.  
  8. /**/
  9. #define        WAIT    40        /*何イベント毎に時刻をチェックするか*/
  10. /**/
  11. #define        SPOSX    4        /*時刻の表示位置*/
  12. #define        SPOSY    2
  13. #define        SATTR    AttrDefault    /*表示文字の色*/
  14. #define        SFONT    12        /*表示文字のサイズ*/
  15.  
  16.  
  17. /**/            /*上記のパラメータからウィンドウサイズを計算する*/
  18. #define        HSIZE    (SFONT*8/2+SPOSX*2)
  19. #define        VSIZE    (SFONT+SPOSY*2)
  20.  
  21. Exec( wp, info )
  22. WindowID    wp;
  23. EventInfo    *info;
  24. {
  25.     static DrawBuf    dbuf[2];
  26.     static char    str[10];
  27.     static unsigned short    count= 1;
  28.  
  29.     switch( info->option ){
  30.  
  31.     case EventInterval:
  32.         /* EventInterval 内での処理は最小限にする */
  33.         if( !--count ){
  34.             static int    bin;
  35.             count= WAIT;
  36.             if( TIMEGET() != bin ){
  37.                 TIMEASC( TIMEBIN( bin= TIMEGET() ), str );
  38.                 WindowDraw( wp, dbuf+1, 1 );
  39.                 return    TRUE;
  40.             }
  41.         }
  42.         break;
  43.  
  44.     case EventRedraw:
  45.         WindowDraw( wp, dbuf, 2 );
  46.         return    TRUE;
  47.  
  48.     case EventOpen:
  49.         /* あらかじめ DrawBuf の設定を行なっておく */
  50.         DrawSetClear( dbuf, 1 );
  51.         DrawSetSymbol( dbuf+1, SPOSX, SPOSY, str, SATTR, SFONT );
  52.         /* EventIntervalを取る */
  53.         WindowSetEventAttr( wp, EventAttrDefault|EventIntervalON );
  54.         WindowRedraw( wp );
  55.         return    TRUE;
  56.  
  57.     case EventClose:
  58.         WindowClose( wp );
  59.         WindowConnectionClose();
  60.         return    TRUE;
  61.  
  62.     case EventMouseSwitch:
  63.         if( info->LeftON ){
  64.             SendData( wp, info, UserString, str );
  65.             return    TRUE;
  66.         }
  67.  
  68.     }
  69.     return    FALSE;
  70. }
  71.  
  72. /* 標準的なメイン関数 */
  73. WindowMain( argc, argv )
  74. char    **argv;
  75. {
  76.     int    x= 100, y= 100;
  77.     AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
  78.     WindowTitleOpen( x, y, HSIZE, VSIZE, NULL, "ゥ", Close|Push, Exec );
  79. }
  80.  
  81.